package com.opages.netty.demo.netty.codec;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @author daizhong.liu
 * @create 2021-12-14 16:27
 **/
public class ServerHandler extends SimpleChannelInboundHandler<Long> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.err.println("客户端:【"+ctx.channel().remoteAddress()+"】,内容：【"+msg+"】");
        ctx.channel().writeAndFlush(7777L);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }
}
